package com.example.dubbo.dto;

import java.io.Serializable;

public class Result<T> implements Serializable {

    public static final String SUCCESS_CODE = "0000";
    public static final String SUCCESS_MESSAGE = "success";
    private static final long serialVersionUID = 4932168009485515323L;
    private String code;

    private String message;

    private T content;

    public Result() {
        this.code = SUCCESS_CODE;
        this.message = SUCCESS_MESSAGE;
    }

    public Result(T content) {
        this.content = content;
        this.message = SUCCESS_MESSAGE;
        this.code = SUCCESS_CODE;
    }

    public Result(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public static Result success() {
        return new Result<>();
    }

    public static <T> Result<T> success(T content) {
        return new Result<>(content);
    }

    public static Result fail(String code, String message) {
        return new Result(code, message);
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getContent() {
        return content;
    }

    public void setContent(T content) {
        this.content = content;
    }
}
